#!/usr/bin/env bash
#content=""
function listFiles()
{
        #1st param, the dir name
        #2nd param, the aligning space
        for file in `ls $1`;
        do
                if [ -d "$1/$file" ]; then
                    listFiles "$1/$file" $2
                else
                  if [[ ${file##*.}  == "png" ]] || [[  ${file##*.} == "jpg" ]] || [[  ${file##*.} == "jpeg" ]]; then
					  echo "$file"
                    fileName=${file/@2x/}
                    fileName=${fileName/@3x/}
                    if [[ -z "$content" ]]; then
                      content=$1"/$fileName"
                    else
                      content=${content}$2$1"/$fileName"
                    fi
                  fi
                fi
        done
}
echo $1
echo $2
echo $3
listFiles $1 $2
if [[ -z "$content" ]]; then
	echo "remove "$3
    rm $3
else
	echo "write to "$3
    echo $content > $3
fi
